var mongoose = require('utils/mongoose.js');
var Coupon = require('../routes/models/Coupon.js');
var moment = require('moment');
// var activityConfig = require('./activity.config.js');
var activityConfig = {
  startTime:{
    date:'2017-01-12',
    full:'2017-01-12 00:00:00'
  }
}
var now = moment(activityConfig.startTime.full);
var create_time = now.format('YYYY-MM-DD HH:mm:ss');
var expiring_time = now.add(10,'day').format('YYYY-MM-DD HH:mm:ss');
var activityStartDate = activityConfig.startTime.date;
var arrays = [
  {
    detail			: activityStartDate+'年前100名用户所得优惠券',
    type			: 'A1',
    create_time 	: create_time,
    expiring_time 	: expiring_time,
    taobao_coupon_id: activityStartDate+'A1',
  },{
    detail			: activityStartDate+'年前101~200名用户所得优惠券',
    type			: 'A2',
    create_time 	: create_time,
    expiring_time 	: expiring_time,
    taobao_coupon_id: activityStartDate+'A2',
  },{
    detail			: activityStartDate+'年后201名用户所得优惠券',
    type			: 'A3',
    create_time 	: create_time,
    expiring_time 	: expiring_time,
    taobao_coupon_id: activityStartDate+'A3',
  },{
    detail      : '优惠券',
    type      : 'A4',
    create_time   : create_time,
    expiring_time   : expiring_time,
    taobao_coupon_id: activityStartDate+'A4',
  },
];
(function   addCoupons(){
  for(let i=0 ;i<arrays.length;i++){
    var coupon = new Coupon(arrays[i]);
    coupon.save(function(err,result){
      if(err){
        console.log(err);
      }else{
        console.log(result);
      }
    });
  }
})();
